package wangyi;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main3 {
    public static void main(String[] args) throws Exception{
        BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
        String s= buf.readLine();
        String[] ss = s.split(" ");
        int[] arr = new int[ss.length];
        for (int i = 0; i < ss.length; i++){
            arr[i] = Integer.parseInt(ss[i]);
        }
        int[] dp = new int[ss.length];
        dp[0] = 1;
        for (int i = 1; i < arr.length; i++){
            if (arr[i] > arr[i - 1]){
                dp[i] = dp[i - 1] + 1;
            } else {
                dp[i] = 1;
            }
        }
        for (int i = arr.length - 2; i >= 0; i--){
            if (arr[i] > arr[i + 1]){
                dp[i] = Math.max(dp[i], dp[i + 1] + 1);
            }
        }
        int res = 0;
        for (int i = 0; i < dp.length; i++){
            res += dp[i];
        }
        System.out.println(res);
    }
}
